package com.wsd.bookkeeping.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wsd.bookkeeping.entity.Record;
import com.wsd.bookkeeping.entity.query.*;
import com.wsd.bookkeeping.vo.*;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface RecordMapper extends BaseMapper<Record> {

    Map<String, Object> queryByRecordId(@Param("id") Integer id);

    /**
     * @MapKey是一个用在返回值为Map的方法上的注解
     * @param query 分页查询参数
     * @return
     */
    @MapKey("id")
    List<Map<String, Object>> queryPage(@Param("query") RecordQuery query);

    /**
     * 获取收入列表
     * @param query
     * @return
     */
    List<IncomeListEntityVO> queryIncomeList(@Param("query") IncomeListQuery query);

    /**
     * 获取用户收入列表
     * @param query
     * @return
     */
    List<UserIncomeListVO> queryUserIncomeList(@Param("query") IncomeListQuery query, @Param("userId") Integer userId);

    /**
     * 获取支出列表
     * @param query
     * @return
     */
    List<OutcomeListEntityVO> queryOutcomeList(@Param("query") OutcomeListQuery query);
    /**
     * 获取用户支出列表
     * @param query
     * @return
     */
    List<UserOutcomeListVO> queryUserOutcomeList(@Param("query") OutcomeListQuery query, @Param("userId") Integer userId);

    @MapKey("type")
    // todo 添加分页查询
    List<Map<String, Object>> queryAmountByDate(@Param("bookId") Integer bookId, @Param("date") String date);

    /**
     * 图标展示-折线图-查询月收入支出总额
     * @param query
     * @return
     */
    List<AccountSummaryVO> querySummaryByType(AccountSummaryQuery query);

    List<AccountClassificationRankVO> queryClassificationRankListByType(AccountClassificationQuery query);

    int deleteByBookId(Integer bookId);
}
